package com.aop.concert;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

@Aspect
public class Audience {

    @Pointcut("execution(* com.aop.concert.Performance.perform(..)))")
    public void performance() {
    }

    @Before("performance()")
    public void silenceCellPhone() {
        System.out.println("表演之前--手机静音");
    }

//    @Before("performance()")
    public void takeSeats() {
        System.out.println("表演之前--就坐");
    }

//    @AfterReturning("performance()")
    public void applause() {
        System.out.println("表演之后--欢呼");
    }

//    @AfterThrowing("performance()")
    public void demandRefund() {
        System.out.println("表演失败--退款");
    }

//    @Around("performance()")
    public void watchPerform(ProceedingJoinPoint joinPoint) {
        System.out.println("表演之前--手机静音");
        System.out.println("表演之前--就坐");
        try {
            joinPoint.proceed();
        } catch (Throwable throwable) {
            System.out.println("表演失败--退款");
        }
        System.out.println("表演之后--欢呼");
    }

}
